package cn.yjh.utils;

import cn.yjh.annotation.RPC;
import cn.yjh.annotation.RPCMapping;
import cn.yjh.annotation.RPCPublish;
import cn.yjh.api.PluginService;
import cn.yjh.api.impl.ConfigurationServiceImpl;

import java.lang.reflect.Method;

/**
 * @DESC:
 * @AUTHOR: YouJinhua
 * @DATE: 2022-01-14 22:11:25
 * @VERSION: 1.0
 */
public class TestDemo {

    public void main(){
        test3();
    }

    public void test1(){
        Class<PluginService> classz = PluginService.class;
        Class<ConfigurationServiceImpl> configurationServiceClass = ConfigurationServiceImpl.class;
        try {
            long l = System.currentTimeMillis();
            Method method = configurationServiceClass.getDeclaredMethod("updateConfiguration",String.class);
            RPCMapping rpcService = AnnotationElementUtils.getMergeAnnotation(method, RPCMapping.class);
            System.out.println("查找耗时：" + (System.currentTimeMillis() - l) + "ms,查找结果为：" + rpcService);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    public void test2(){
        Class<PluginService> classz = PluginService.class;
        try {
            long l = System.currentTimeMillis();
            RPC rpcService = AnnotationElementUtils.getMergeAnnotation(classz, RPC.class);
            System.out.println("查找耗时：" + (System.currentTimeMillis() - l) + "ms,查找结果为：" + rpcService);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void test3(){
        Class<ConfigurationServiceImpl> classz = ConfigurationServiceImpl.class;
        try {
            long l = System.currentTimeMillis();
            RPC rpcService = AnnotationElementUtils.getMergeAnnotation(classz, RPC.class);
            System.out.println("查找耗时：" + (System.currentTimeMillis() - l) + "ms,查找结果为：" + rpcService);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
